#ifndef __VLOG_VLOG_H__
#define __VLOG_VLOG_H__

#include "appender/filelogappender.h"
#include "appender/logappender.h"
#include "appender/stdcoutappender.h"
#include "logformatter.h"
#include "loglevel.h"

#include "logevent.h"
#include "logeventwarp.h"
#include "logger.h"
#include "loggermanger.h"
#include "util.h"

#define VLOG_GET_ROOT() vlog::LoggerMgr::GetInstance()->GetRoot();

#define VLOG_GET_LOG(name) vlog::LoggerMgr::GetInstance()->GetLogger(name);

#if 0
#define VLOG_LOG_FMT_LEVEL(logger, level)                                                                              \
    if (level <= logger->GetLogLevel())                                                                                \
    vlog::LogEventWarp(logger, vlog::event::LogEvent::ptr(new vlog::event::LogEvent(                                   \
                                   __FILE__, level, __LINE__, vlog::util::GetTimeMs(), vlog::util::GetTimeMs(),        \
                                   vlog::util::GetThreadID(), vlog::util::GetThreadName(), std::string(__func__),      \
                                   logger->GetLogName())))                                                             \
        .GetMessageSS()
#endif

#define VLOG_LOG_FMT_LEVEL(logger, level)                                                                              \
    if (level <= logger->GetLogLevel())                                                                                \
    vlog::LogEventWarp(logger, vlog::event::LogEvent::ptr(std::make_shared<vlog::event::LogEvent>(                     \
                                   __FILE__, level, __LINE__, vlog::util::GetTimeMs(), vlog::util::GetTimeMs(),        \
                                   vlog::util::GetThreadID(), vlog::util::GetThreadName(), std::string(__func__),      \
                                   logger->GetLogName())))                                                             \
        .GetMessageSS()

#define VLOG_FATAL(logger) VLOG_LOG_FMT_LEVEL(logger, vlog::LogLevel::Level::FATAL)
#define VLOG_INFO(logger) VLOG_LOG_FMT_LEVEL(logger, vlog::LogLevel::Level::INFO)
#define VLOG_WARN(logger) VLOG_LOG_FMT_LEVEL(logger, vlog::LogLevel::Level::WARN)
#define VLOG_ERROR(logger) VLOG_LOG_FMT_LEVEL(logger, vlog::LogLevel::Level::ERROR)
#define VLOG_DEBUG(logger) VLOG_LOG_FMT_LEVEL(logger, vlog::LogLevel::Level::DEBUG)

#endif